package ssf.app.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ssf.app.service.ServiceManager;
import ssf.core.Constants;
import ssf.core.bean.BeanManager;
import ssf.core.common.CommonBaseAction;

public class BaseAction extends CommonBaseAction {
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return mapping.findForward(Constants.RETURN_SUCCESS);
	}

	/**
	 * ServiceManager
	 */
	public ServiceManager getServMgr() {
		return (ServiceManager) BeanManager.getBean("serviceManager");
	}

	/**
	 * 获取登录用户对象
	 */
	@SuppressWarnings("unchecked")
	public Map getLoginUser(HttpServletRequest request) {
		return (Map) request.getSession().getAttribute(Constants.LOGIN_USER);
	}

	/**
	 * 获取登录用户的用户Id
	 */
	public String getLoginUserId(HttpServletRequest request) {
		return getLoginUser(request).get("userId").toString();
	}
}
